import Vue from 'vue'
import Vuex from 'vuex'
import cloneDeep from 'lodash/cloneDeep'
import common from './modules/common'
import user from './modules/user'

Vue.use(Vuex)

export default new Vuex.Store({
	state: {
		userId: '',
		relationId: '',
		languageList: [],
		languageValue: '',
		currencyInfo: {},//选中的币种信息
		currencyList:[],//币种列表
		sousuoValue:'',
	},
	modules: {
		common,
		user
	},
	mutations: {
		// 重置vuex本地储存状态
		resetStore(state) {
			// if (window.SITE_CONFIG) {
				Object.keys(state).forEach((key) => {
					console.error('key-----', key)
					state[key] = cloneDeep(window.SITE_CONFIG['storeState'][key])
				})
			// }

		},
		updateUserId(state, userId) {
			state.userId = userId
		},
		updateRelationId(state, relationId) {
			state.relationId = relationId
		},
		languageList(state, languageList) {
			state.languageList = languageList
		},
		languageValue(state, languageValue) {
			state.languageValue = languageValue
		},
		currencyInfo(state, currencyInfo) {
			state.currencyInfo = currencyInfo
		},
		currencyList(state, currencyList) {
			state.currencyList = currencyList
		},
		sousuoValue(state, sousuoValue) {
			state.sousuoValue = sousuoValue
		}
	},
	strict: process.env.NODE_ENV !== 'production'
})
